
define([
'zepto',
'underscore',
'backbone',
"text!templates/head.html",
"text!templates/olpay/detail.html",
], function($, _, Backbone,template, detail){
	return Backbone.View.extend({
		$el:$("body"),
		el:$("body")[0],
		template:_.template(template),
		templateDetail:_.template(detail),
		events : {
			"touchstart #head_back" : "back"
			,"click #head_back" : "back"
			,"touchend #more": "more"
			,"click #more": "more"
			,"touchend #detail": "detail"
			,"click #detail": "detail"
			,"touchend #closeBankList": 'closeBankList'
			,"click #closeBankList": 'closeBankList'
		},
		isMore: true,
		initialize: function(options) {
            this.router = options.router;
			this.render();
			//$("#main").css({"min-height":($(window).height()-$("#head").height()-$("#home").height()-3*$(".footer").height())});
	    },
		more: function (e) {
			if (this.isMore) {
				$("#order").css({"height": "6.4rem"});
				$("#more").html("收起");
			} else {
				$("#order").css({"height": "2.6rem"});
				$("#more").html("更多");
			}
			this.isMore = !this.isMore;
            e.preventDefault();
		},
		detail: function(e) {
			if(wData.tradeVoucherLength == 1){
				if (this.isMore) {
					$("#order").css({"height": "6.4rem"});
					$("#more").html("收起");
				} else {
					$("#order").css({"height": "2.6rem"});
					$("#more").html("更多");
				}
			}
			else if(wData.tradeVoucherLength > 1) {
				$('#home').append(this.templateDetail(wData.bankList));
				$(".chooseBankBg").css({"height": ($(window).height() - $("#head").height())});
				$(".detailList").css({"height": ($(window).height() - $("#head").height() * 2.6)});
				App.title("订单详情");
			}
			this.isMore = !this.isMore;
            e.preventDefault();
		},
		closeBankList: function (e) {
            $("#bankList").remove();
            App.title("订单支付");
            e.preventDefault();
        },
        back:function(e){
            back();
           // var target = $(e.currentTarget),
           //     url =target.attr("url");
           // url !=null && (location.hash = url);
            e.preventDefault();
        },
        setData:function(title){
            title && this.H1.text(title);
            !title && this.H1.text("买车险");
        },
	    render:function(){
	    	var html = this.template();
	    	this.$el.html(html);
            this.H1 = this.$el.find("h1");
	    }
	});
});